<template>
    <a-card :bordered="false">
        <!-- 查询区域 -->
        <div class="table-page-search-wrapper">
            <a-form layout="inline" @keyup.enter.native="searchQuery">
                <a-row :gutter="24">

                </a-row>
            </a-form>
        </div>
        <!-- 查询区域-END -->

        <!-- 操作按钮区域 -->
        <div class="table-operator">
            <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
            <a-button type="primary" icon="download" @click="handleExportXls('eip_insulation_torsion')">导出</a-button>
            <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader"
                      :action="importExcelUrl" @change="handleImportExcel">
                <a-button type="primary" icon="import">导入</a-button>
            </a-upload>
            <a-dropdown v-if="selectedRowKeys.length > 0">
                <a-menu slot="overlay">
                    <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>
                </a-menu>
                <a-button style="margin-left: 8px">批量操作<a-icon type="down"/>
                </a-button>
            </a-dropdown>
        </div>

        <!-- table区域-begin -->
        <div>
            <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
                <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{
                selectedRowKeys.length }}</a>项
                <a style="margin-left: 24px" @click="onClearSelected">清空</a>
            </div>

            <a-table
                    ref="table"
                    size="middle"
                    bordered
                    rowKey="puid"
                    :columns="columns"
                    :dataSource="dataSource"
                    :pagination="ipagination"
                    :loading="loading"
                    :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
                    @change="handleTableChange">

                <template slot="imgSlot" slot-scope="text">
                    <span v-if="!text" style="font-size: 12px;font-style: italic;">无此图片</span>
                    <img v-else :src="getImgView(text)" height="25px" alt="图片不存在"
                         style="max-width:80px;font-size: 12px;font-style: italic;"/>
                </template>
                <template slot="fileSlot" slot-scope="text">
                    <span v-if="!text" style="font-size: 12px;font-style: italic;">无此文件</span>
                    <a-button
                            v-else
                            :ghost="true"
                            type="primary"
                            icon="download"
                            size="small"
                            @click="uploadFile(text)">
                        下载
                    </a-button>
                </template>

                <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>

          <a-divider type="vertical"/>
          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down"/></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.puid)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>

            </a-table>
        </div>

        <eipInsulationTorsion-modal ref="modalForm" @ok="modalFormOk"></eipInsulationTorsion-modal>
    </a-card>
</template>

<script>

    import {JeecgListMixin} from '@/mixins/JeecgListMixin'
    import EipInsulationTorsionModal from './modules/EipInsulationTorsionModal'
    import {initDictOptions, filterDictText} from '@/components/dict/JDictSelectUtil'

    export default {
        name: "EipInsulationTorsionList",
        mixins: [JeecgListMixin],
        components: {
            EipInsulationTorsionModal
        },
        data() {
            return {
                description: 'eip_insulation_torsion管理页面',
                // 表头
                columns: [
                    {
                        title: '采购方总部编码',
                        align: "center",
                        dataIndex: 'purchaserHqCode',
                        customRender: (text, record, index) => {
                            //字典值替换通用方法
                            return filterDictText(this.purchaserHqCodeDictOptions, text)
                        }
                    },
                    {
                        title: '供应商名称',
                        align: "center",
                        dataIndex: 'supplierName'
                    },
                    {
                        title: '供应商工单编号',
                        align: "center",
                        dataIndex: 'supplierWorkNo'
                    },
                    {
                        title: '采集规范版本号',
                        align: "center",
                        dataIndex: 'standardVersion'
                    },
                    {
                        title: '规格型号编码',
                        align: "center",
                        dataIndex: 'modelCode',
                        customRender: (text, record, index) => {
                            //字典值替换通用方法
                            return filterDictText(this.modelCodeDictOptions, text)
                        }
                    },
                    {
                        title: '物资品类类型',
                        align: "center",
                        dataIndex: 'categoryType',
                        customRender: (text, record, index) => {
                            //字典值替换通用方法
                            return filterDictText(this.categoryTypeDictOptions, text)
                        }
                    },
                    {
                        title: '采集时间',
                        align: "center",
                        dataIndex: 'checkTime',
                        customRender: function (text) {
                            return !text ? "" : (text.length > 10 ? text.substr(0, 10) : text)
                        }
                    },
                    {
                        title: '入数采中心时间',
                        align: "center",
                        dataIndex: 'putCenterTime',
                        customRender: function (text) {
                            return !text ? "" : (text.length > 10 ? text.substr(0, 10) : text)
                        }
                    },
                    {
                        title: '工序',
                        align: "center",
                        dataIndex: 'pdCode'
                    },
                    {
                        title: '感知过程',
                        align: "center",
                        dataIndex: 'processType'
                    },
                    {
                        title: '(抗扭)检验结果是否合格',
                        align: "center",
                        dataIndex: 'torsionalStrength',
                        customRender: (text, record, index) => {
                            //字典值替换通用方法
                            return filterDictText(this.isQualifyDictOptions, text)
                        }
                    },
                    {
                        title: '工频额定值',
                        align: "center",
                        dataIndex: 'industrialFrequencyUn'
                    },
                    {
                        title: '工频值',
                        align: "center",
                        dataIndex: 'industrialFrequency'
                    },
                    {
                        title: '额定局放值',
                        align: "center",
                        dataIndex: 'partialDischargeUn'
                    },
                    {
                        title: '局放值',
                        align: "center",
                        dataIndex: 'partialDischarge'
                    },
                    {
                        title: '(绝缘操作杆(扭杆))检验结果是否合格',
                        align: "center",
                        dataIndex: 'isQualify',
                        customRender: (text, record, index) => {
                            //字典值替换通用方法
                            return filterDictText(this.isQualifyDictOptions, text)
                        }
                    },
                    {
                        title: '(绝缘操作杆(扭杆))检查结果附件文件名',
                        align: "center",
                        dataIndex: 'checkResult'
                    },
                    {
                        title: '(绝缘操作杆(扭杆))检查结果附件对象',
                        align: "center",
                        dataIndex: 'checkResultObj'
                    },
                    {
                        title: '操作',
                        dataIndex: 'action',
                        align: "center",
                        scopedSlots: {customRender: 'action'},
                    }
                ],
                url: {
                    list: "/eipInsulationTorsion/list",
                    delete: "/eipInsulationTorsion/delete",
                    deleteBatch: "/eipInsulationTorsion/deleteBatch",
                    exportXlsUrl: "/eipInsulationTorsion/exportXls",
                    importExcelUrl: "/eipInsulationTorsion/importExcel",
                },
                dictOptions: {}
            }
        },
        computed: {
            importExcelUrl: function () {
                return `${window._CONFIG['excelURL']}/${this.url.importExcelUrl}`;
                // return `http://10.89.33.69:8088/jeecg-boot/${this.url.importExcelUrl}`;
            }
        },
        methods: {
            initDictConfig() {
                initDictOptions('purchaserHqCode').then((res) => {
                    if (res.success) {
                        this.purchaserHqCodeDictOptions = res.result
                    }
                });
                initDictOptions('modelCode').then((res) => {
                    if (res.success) {
                        this.modelCodeDictOptions = res.result
                    }
                });
                initDictOptions('categoryType').then((res) => {
                    if (res.success) {
                        this.categoryTypeDictOptions = res.result
                    }
                });
                initDictOptions('isQualify').then((res) => {
                    if (res.success) {
                        this.isQualifyDictOptions = res.result
                    }
                })
            }
        }
    }
</script>
<style scoped>
    @import '~@assets/less/common.less'
</style>